import threading
import datetime

analogue_value = 0.0001
class clock(object):
    timer = None
    __now = None

    def __init__(self):
        super().__init__()
        self.run()

    def run(self):
        self.timer = threading.Timer(0.5, self.tick)
        self.timer.start()

    def tick(self):
        self.__now = datetime.datetime.now()
        strTime = self.__now.strftime('%Y-%m-%d %H:%M:%S.%f')
        print("当前时间为：" + strTime)
        global analogue_value
        analogue_value += 0.0001
        print(analogue_value)        
        self.run() #重复设置定时器，以重复


myClock = clock()